package com.skyline.user.mapper;

import java.sql.ResultSet;
import java.sql.SQLException;

import org.springframework.jdbc.core.RowMapper;

import com.skyline.base.type.Activity;
import com.skyline.base.type.IdolType;
import com.skyline.user.model.Fan;

public class FanMapper implements RowMapper<Fan> {

	private final static String COLUMN_ID = "id";
	private final static String COLUMN_FAN_ID = "fanId";
	private final static String COLUMN_FAN_NICKNAME = "fanNickname";
	private final static String COLUMN_FAN_PORTRAIT = "fanPortrait";
	private final static String COLUMN_IDOL_ID = "idolId";
	private final static String COLUMN_IDOL_NICKNAME = "idolNickname";
	private final static String COLUMN_IDOL_PORTRAIT = "idolPortrait";
	private final static String COLUMN_IDOL_TYPE = "idolType";
	private final static String COLUMN_ATTENTION_TYPE="attentionType";
	private final static String COLUMN_ACTIVITY = "activity";
	private final static String COLUMN_CREATTIME = "createTime";
	private final static FanMapper MAPPER = new FanMapper();

	public static FanMapper getMapper() {
		return MAPPER;
	}

	public Fan mapRow(ResultSet rs, int rowNum) throws SQLException {
		Fan fan = new Fan();
		fan.setId(rs.getLong(COLUMN_ID));
		fan.setFanId(rs.getLong(COLUMN_FAN_ID));
		fan.setFanNickname(rs.getString(COLUMN_FAN_NICKNAME));
		fan.setFanPortrait(rs.getString(COLUMN_FAN_PORTRAIT));
		fan.setIdolId(rs.getLong(COLUMN_IDOL_ID));
		fan.setIdolNickname(rs.getString(COLUMN_IDOL_NICKNAME));
		fan.setIdolPortrait(rs.getString(COLUMN_IDOL_PORTRAIT));
		fan.setIdolType(IdolType.valueOf(rs.getString(COLUMN_IDOL_TYPE)));
		fan.setAttentionType(rs.getBoolean(COLUMN_ATTENTION_TYPE));
		fan.setActivity(Activity.valueOf(rs.getString(COLUMN_ACTIVITY)));
		fan.setCreateTime(rs.getTimestamp(COLUMN_CREATTIME));
		return fan;
	}
}
